//Listener que se encarga de inicializar el Log4j
package com.mmaingenieria.MMAGestor.listeners;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Listener implements ServletContextListener {
	//Atributos
	private static final String path_properties = "C:/eclipse/TOMCAT/webapps/MMAGestor/WEB-INF/classes/log4j.properties"; //PARA FUNCIONAR EN LOCAL
	//private static final String path_properties = "/var/cache/tomcat6/PSA/mmaingenieria.net/MMAGestor/WEB-INF/classes/log4j.properties"; //PARA FUNCIONAR EN VPS
	
	
    public Listener() {
    }
    
    public void contextInitialized(ServletContextEvent sce) {
    	try{
    	PropertyConfigurator.configure(path_properties);
		Logger.getLogger(this.getClass()).trace("Iniciamos contexto Listener");
    	}catch(Exception e){
    		Logger.getLogger(this.getClass()).error("Excepcion generada al arrancar el Listener");
    	}
    }    
    public void contextDestroyed(ServletContextEvent arg0) {
    	Logger.getLogger(this.getClass() ).trace("Destruimos contexto Listener");
    }	
}
